import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class JobRunMain {
    public static void main(String[] args) throws JobParametersInvalidException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        Job job = context.getBean("modelJob", Job.class);//读取文件
//        Job job = context.getBean("dataBaseModelJob", Job.class);//读取数据库
        JobParametersBuilder builder = new JobParametersBuilder();
        builder.addString("inputFile","E:/open_card.csv" );
        JobExecution jobExecution = jobLauncher.run(job, builder.toJobParameters());
        System.out.println("结果："+jobExecution.toString());
    }
}
